import ariter from './ariter'
import bluetork from './bluetork'
import { useDeviceStore } from '@/stores/'

function protosAdapter() {
  // 获取设备的属性
  const deviceStore = useDeviceStore()
  // 提取设备名称前3个字符
  const startsWithStr = deviceStore.curDevice.name.slice(0, 3)

  // 匹配协议
  switch (startsWithStr) {
    case 'BEM':
      getApp().globalData.protosUtils = ariter
      break
    case 'XHX':
      getApp().globalData.protosUtils = bluetork
      break
    default:
      uni.$globalMessage.alert({
        msg: '该设备不在系统中，请更换设备或者联系管理员',
        title: '提示',
      })
      break
  }
}
export default protosAdapter
